package com.pussinboots.morning.sync.job;

import com.pussinboots.morning.sync.service.ISyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by TaoShuai on 2019/9/22.
 */
@Component
public class SyncJob {
    @Autowired
    private ISyncService syncService;

    /**
     * 订单回执同步
     * 每5分钟执行一次
     */
    @Scheduled(cron = "0 0/5 * * * *")
    void syncOrder(){
        syncService.syncOrder();
    }

    /**
     * 商品同步
     *      * 每天凌晨1点执行
     */
    @Scheduled(cron = "0 0 1 * * *")
    void syncProduct() {
        syncService.syncStockOrProduct(true);
    }

    /**
     * 库存同步
     * 每5分钟执行一次
     */
    @Scheduled(cron = "0 0/5 * * * *")
    void syncStock() {
        syncService.syncStockOrProduct(false);
    }
}
